function plot_timelines(TL)
% Plot timelines
%
%   plot_timelines(TL);
%

% Created by Dahua Lin, on Nov 24, 2010
%

%% verify input arguments

if ~(isfloat(TL) && ndims(TL) == 2)
    error('plot_timelines:invalidarg', 'TL should be a numeric matrix.');
end

%% main

[m, n] = size(TL);

% plot baselines

bx = repmat([0 n-1 nan], 1, m);
by = reshape([1:m; 1:m; nan(1, m)], 1, 3*m);

plot(bx, by, 'b--');

axis([0, n, 0.8, m+1]);

% plot time lines
for i = 1 : m
    tl = TL(i, :);
    hold on;
    plot(0:n-1, 0.8 * tl + i);
end

set(gca, 'YTick', 1:m);
